import http from "@/api";
import { ResPage, OrgManager } from "@/api/interface/index";
import qs from "qs";
/**
 * @name
 */
// 分页查询未接电话
export const findReportPicturePage = (params: {}, header: string, unhandle: string[]) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      if (unhandle.length > 0) {
        if (unhandle.includes(`${key}`)) {
          newobj[`${key}`] = `${params[key]}`;
        } else {
          newobj[header + "." + `${key}`] = `${params[key]}`;
        }
      } else {
        newobj[header + "." + `${key}`] = `${params[key]}`;
      }
    });
  } else {
    newobj = params;
  }
  return http.post(`/pages/reportPicture!findReportPicturePage.action`, qs.stringify(newobj));
};

/**
 * @name 保存
 */
// 保存
export const saveReportPicture = (params: {}, header: string, unhandle: string[]) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      if (unhandle.length > 0) {
        if (unhandle.includes(`${key}`)) {
          newobj[`${key}`] = `${params[key]}`;
        } else {
          newobj[header + "." + `${key}`] = `${params[key]}`;
        }
      } else {
        newobj[header + "." + `${key}`] = `${params[key]}`;
      }
    });
  } else {
    newobj = params;
  }
  return http.post(`/pages/reportPicture!save.action`, qs.stringify(newobj));
};

/**
 * @name update
 */
// update
export const updateReportPicture = (params: {}, header: string, unhandle: string[]) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      if (unhandle.length > 0) {
        if (unhandle.includes(`${key}`)) {
          newobj[`${key}`] = `${params[key]}`;
        } else {
          newobj[header + "." + `${key}`] = `${params[key]}`;
        }
      } else {
        newobj[header + "." + `${key}`] = `${params[key]}`;
      }
    });
  } else {
    newobj = params;
  }
  return http.post(`/pages/reportPicture!update.action`, qs.stringify(newobj));
};

/**
 * @name
 */
export const deleteReportPicture = (ids: string) => {
  return http.post(`/pages/reportPicture!deletereportPicture.action` + ids, qs.stringify({}));
};

/**
 * @name
 */
export const findTemplateUrl = () => {
  return http.post(`/pages/reportPicture!findTemplateUrl.action`, qs.stringify({}));
};
export const saveTemplateUrl = (url: string) => {
  return http.post(`/pages/reportPicture!saveTemplateUrl.action?url=` + url, qs.stringify({}));
};
